﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    //WebUserControl1.GoogleMap
    protected void Page_Load(object sender, EventArgs e)
    {
        WebUserControl1.GoogleMap.Width = "500px";
        WebUserControl1.GoogleMap.Height = "500px";
        WebUserControl1.GoogleMap.MapType = GoogleMapObject.GoogleMapType.HYBRID;// GoogleMapType.
        WebUserControl1.GoogleMap.ZoomLevel = 10;

        #region Comment
        //CustomControl control = new CustomControl();
        //control.position = CustomControl.PositionControl.RIGHT_TOP;
        //control.BackgroundColor = "white";
        //control.BorderStyle = "solid";
        //control.BorderWidth = "2px";
        //control.Cursor = "pointer";
        //control.TextAlign = "center";
        //control.Title = "Click to set the map to Home";

        //control.FontFamily = "Arial,sans-serif";
        //control.FontSize = "12px";
        //control.PaddingLeft = "4px";
        //control.PaddingRight = "4px";
        //control.InnerHTML = "Home";

        //CustomControl control1 = new CustomControl();
        //control1.position = CustomControl.PositionControl.RIGHT_BOTTOM;
        //control1.BackgroundColor = "white";
        //control1.BorderStyle = "solid";
        //control1.BorderWidth = "2px";
        //control1.Cursor = "pointer";
        //control1.TextAlign = "center";
        //control1.Title = "Click to set the map to (0,0)";

        //control1.FontFamily = "Arial,sans-serif";
        //control1.FontSize = "12px";
        //control1.PaddingLeft = "4px";
        //control1.PaddingRight = "4px";
        //control1.InnerHTML = "Home1";

        //control.Clicked += new CustomControl.EventHandlerForControl(control_Clicked);
        //control1.Clicked += new CustomControl.EventHandlerForControl(control_Clicked1);
        //WebUserControl1.GoogleMap.AddControl(control);
        //WebUserControl1.GoogleMap.AddControl(control1);

        //Style style1 = new Style();

        //style1.FeatureType = Style.MapTypeStyleFeatureType.all;
        //style1.saturation = -80;

        //Style style2 = new Style();

        //style2.FeatureType = Style.MapTypeStyleFeatureType.poi_park;
        //style2.hue = "#ff0022";
        //style2.saturation = 40;

        //WebUserControl1.GoogleMap.AddStyle(style1);
        //WebUserControl1.GoogleMap.AddStyle(style2);
        //WebUserControl1.GoogleMap.MarkerClicked += new GoogleMapObject.EventHandlerForMarker(GoogleMap_MarkerClicked);
        //WebUserControl1.GoogleMap.MarkerDrag += new GoogleMapObject.EventHandlerForMarker(GoogleMap_MarkerDrag);
        #endregion
        


        WebUserControl1.GoogleMap.MouseClick += new GoogleMapObject.EventHandlerForGoogleMapMouse(GoogleMap_MouseClick);
    }
    static int i = 1;
    void GoogleMap_MouseClick(double latitude, double longitude)
    {
        GooglePoint GP = new GooglePoint();
        //GP.Address = txtAddress.Text;
        GP.ID = i.ToString();
        GP.IconImage = "Icons/1.png";// +i + ".png";
        i++;
        GP.Latitude = latitude;
        GP.Longitude = longitude;
        GP.InfoHTML = GP.ID;
        WebUserControl1.GoogleMap.Markers.Add(GP);
    }

    //void GoogleMap_MarkerDrag(string pID)
    //{
    //    string t = pID;
    //} 

    //void GoogleMap_MarkerClicked(string pID)
    //{
    //    string t = pID;
    //}

    //void control_Clicked()
    //{
    //    WebUserControl1.GoogleMap.CenterPoint.Latitude = 41.850033;
    //    WebUserControl1.GoogleMap.CenterPoint.Longitude = -87.6500523;
    //}

    //void control_Clicked1()
    //{
    //    WebUserControl1.GoogleMap.CenterPoint.Latitude = 0;
    //    WebUserControl1.GoogleMap.CenterPoint.Longitude = 0;
    //}

    protected void Button1_Click(object sender, EventArgs e)
    {
        GooglePoint GP = new GooglePoint();
        GP.Address = txtAddress.Text;
        GP.ID = "3";
        //GeocodeAddress() function will geocode address and set Latitude and Longitude of GP(GooglePoint) to it's respected value.
        if (GP.GeocodeAddress())
        {
            //Once GP is geocoded, you can add it to google map.
            GP.InfoHTML = GP.Address;
            //Set GP as center point.
            WebUserControl1.GoogleMap.CenterPoint = GP;
            //Clear any existing
            WebUserControl1.GoogleMap.Markers.Clear();
            //GP.Draggable = true;
            //Add geocoded GP to GoogleMapObject
            WebUserControl1.GoogleMap.Markers.Add(GP);
            WebUserControl1.GoogleMap.ZoomLevel = 15;

        }
        else
        {

        }
    }

}